/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FlightFrame.java
 *
 * Created on 2009-12-1, 22:44:38
 */

package View;

import Model.FlightsI;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class FlightFrame extends javax.swing.JFrame {
private String user;
    /** Creates new form FlightFrame */
    public FlightFrame() {
        super("Flight");
        initComponents();
    }
      public FlightFrame(FlightsI fi) {
        super("Flight");
         initComponents();
         initJLabel(fi);
       
  
    }

    public FlightFrame(FlightsI fi,String user) {
        super("Flight");
         initComponents();
         name_jlb.setText("Welcome,    " + user + "!");
        initJLabel(fi);
       this.user=user;
    }

    public void initJLabel(FlightsI fi){
        plane_id_jlb.setText("Plane ID:"+fi.getPlaneid());
        start_airport_jlb.setText("Start Airport: "+fi.getSairport());
        get_airport_jlb.setText("Destination Airport: "+fi.getGairport());
        start_time_jlb.setText("Start Time: "+fi.getStime());
        get_time_jlb.setText("Get time: "+fi.getGtime());
        
        ticket_price_jlb.setText("Ticket Price: "+fi.getTicketprice());

        
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        back_jbt = new javax.swing.JButton();
        logout_jbt = new javax.swing.JButton();
        start_airport_jlb = new javax.swing.JLabel();
        get_airport_jlb = new javax.swing.JLabel();
        start_time_jlb = new javax.swing.JLabel();
        get_time_jlb = new javax.swing.JLabel();
        plane_id_jlb = new javax.swing.JLabel();
        ticket_price_jlb = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        name_jlb = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Your flight ticket information in here:");

        back_jbt.setBackground(new java.awt.Color(51, 51, 51));
        back_jbt.setForeground(new java.awt.Color(255, 255, 25));
        back_jbt.setText("Back");
        back_jbt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                back_jbtActionPerformed(evt);
            }
        });

        logout_jbt.setBackground(new java.awt.Color(51, 51, 51));
        logout_jbt.setForeground(new java.awt.Color(255, 255, 25));
        logout_jbt.setText("Logout");
        logout_jbt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logout_jbtActionPerformed(evt);
            }
        });

        jButton1.setBackground(new java.awt.Color(51, 51, 51));
        jButton1.setForeground(new java.awt.Color(255, 255, 25));
        jButton1.setText("Book it");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(back_jbt)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(name_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 269, Short.MAX_VALUE)
                .addComponent(logout_jbt))
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(269, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(ticket_price_jlb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(start_time_jlb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
                        .addComponent(get_time_jlb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(get_airport_jlb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(start_airport_jlb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(plane_id_jlb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(166, 166, 166))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(348, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(120, 120, 120))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(back_jbt)
                    .addComponent(logout_jbt)
                    .addComponent(name_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(plane_id_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(start_airport_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(get_airport_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(start_time_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(get_time_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ticket_price_jlb, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(86, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void back_jbtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_back_jbtActionPerformed
            SuccessFrame su=new SuccessFrame(user);
            su.setVisible(true);
            this.dispose();
    }//GEN-LAST:event_back_jbtActionPerformed

    private void logout_jbtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logout_jbtActionPerformed
             LoginFrame login=new LoginFrame();
             login.setVisible(true);
             this.dispose();
    }//GEN-LAST:event_logout_jbtActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
         JOptionPane.showMessageDialog(null, "Book flight Success");
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
  
   public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FlightFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton back_jbt;
    private javax.swing.JLabel get_airport_jlb;
    private javax.swing.JLabel get_time_jlb;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton logout_jbt;
    private javax.swing.JLabel name_jlb;
    private javax.swing.JLabel plane_id_jlb;
    private javax.swing.JLabel start_airport_jlb;
    private javax.swing.JLabel start_time_jlb;
    private javax.swing.JLabel ticket_price_jlb;
    // End of variables declaration//GEN-END:variables

}
